package com.ruoyi.api.controller;

import cn.hutool.json.JSONObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.api.dto.evaluate.resp.EnvironmentMonthStatisticsRespDto;
import com.ruoyi.api.dto.evaluate.resp.EnvironmentYearStatisticsRespDto;
import com.ruoyi.api.service.EvaluateStatService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.stat.evaluate.service.IEvaluateStatService;

import lombok.RequiredArgsConstructor;

/**
 * 市环境测评数据统计汇总
 *
 * @author cc
 * @date 2023-04-28
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/stat/evaluate")
public class EvaluateStatController extends BaseController {

	private final IEvaluateStatService iEvaluateStatService;
	private final EvaluateStatService evaluateStatService;

	/**
	 * 市环境测评数据 - 月
	 * @param date 查询日期，yyyy-MM-dd，默认当前月
	 * @return
	 */
	@GetMapping("/environmentMonthStatistics")
	public R<JSONObject> getEnvironmentMonthStatistics() {
		return R.ok(this.evaluateStatService.getEnvironmentMonthStatistics());
	}

	/**
	 * 市环境测评数据 - 年
	 * @param date 查询日期，yyyy-MM-dd，最近一年
	 * @return
	 */
	@GetMapping("/environmentYearStatistics")
	public R<JSONObject> getEnvironmentYearStatistics() {
		return R.ok(this.evaluateStatService.getEnvironmentYearStatistics());
	}

	@GetMapping("/createData")
	public R<Void> createData(@RequestParam(name = "startTime", defaultValue = "") String startTime,
			@RequestParam(name = "endTime", defaultValue = "") String endTime) {
		return toAjax(this.iEvaluateStatService.createStatData(startTime, endTime));
	}
}
